home *** CD-ROM | disk | FTP | other *** search
- // Fireworks generic HTML & JavaScript for single images & imagemaps.
- // Version 2.0 24JAN99
-
- // To export HTML without comments change the value of variable doComments to "false".
- var doComments=true;
-
- // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
- // include HTML and JavaScript in the exported file.
- function WRITE_HTML_COMMENT(str) {
- if (doComments) WRITE_HTML("<!--"+str+"-->\n");
- }
-
- function WRITE_JS_COMMENT(str) {
- if (doComments) WRITE_HTML("/* "+str+" */\n");
- }
-
- // Write general comments for copying and pasting Fireworks-generated code into existing HTML documents.
- WRITE_HTML_COMMENT("To put this html into an existing HTML document, you must copy the JavaScript and");
- WRITE_HTML_COMMENT("paste it in a specific location within the destination HTML document. You must then copy");
- WRITE_HTML_COMMENT("and paste code for the image with map in a different location.");
- WRITE_HTML("\n");
-
-
- WRITE_HTML("<html>\n");
- WRITE_HTML("\n");
-
- WRITE_HTML("<head>\n");
- WRITE_HTML("\n");
-
- // Use Base Name from export dialog as document title.
- WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
- WRITE_HTML("\n");
-
- // Write Meta tags.
- WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
- var charSet = App.getPref("HtmlCharSet");
- if (charSet == "") charSet = "iso-8859-1";
- WRITE_HTML(charSet + "\">\n");
- WRITE_HTML("<meta name=\"description\" content=\"Fireworks Image Map\">\n");
- WRITE_HTML("\n");
-
- // Write HTML target and date created.
- var d = new Date();
- WRITE_HTML("<!-- Fireworks 2.0 Generic target. \n Created ", d, " -->\n");
- WRITE_HTML("\n");
-
- // Declare variables for processing Behaviors.
- var hasImagemap = false;
- var hasStatusMessages = false;
-
- var kActionStatusMessage = 1;
- var kActionSwapImage = 2;
- var kActionRadioGroup = 3;
-
- var kEventMouseOver = 0;
- var kEventOnClick = 1;
- var kEventMouseOut = 2;
-
- // Write a client-side imagemap
- if (exportDoc.clientMap) {
- var i = 0;
- while (i < imagemap.numberOfURLs) {
- hasImagemap = true; // at least 1 url in the imagemap.
- for (var j=0; j<imagemap[i].behaviors.numberOfBehaviors; j++) {
- var curBehavior = imagemap[i].behaviors[j];
- if (curBehavior.action == kActionStatusMessage) {
- hasStatusMessages = true;
- }
- }
- i++;
- }
- if (exportDoc.hasBackgroundLink) {
- hasImagemap = true;
- }
- }
-
- /* Note: In simple imagemaps using the template Imagemap.htt, the only available
- behavior is the status bar message. Otherwise, the Slices.htt template is used. */
- function ProcessBehavior(theCurBehaviors) {
- var gotJavascript = false;
- var overStat = false;
- var hitStat = false;
- var outStat = false;
- var eraseStatOnRestore = false;
- for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
- var curBehavior = theCurBehaviors[i];
- var curJavascript = "";
- var gotStat = false;
- if (curBehavior.action == kActionStatusMessage) {
- gotJavascript = true;
- gotStat = true;
- var statMsg = curBehavior.statusText;
- var restore = curBehavior.restoreOnMouseout;
- curJavascript += "dmim('" + statMsg + "');";
- if (restore) {
- eraseStatOnRestore = true;
- }
- } else {
- continue;
- }
- if (curBehavior.event == kEventMouseOver) {
- javaOver += curJavascript;
- if (gotStat) overStat = true;
- }
- if (curBehavior.event == kEventMouseOut) {
- javaOut += curJavascript;
- if (gotStat) outStat = true;
- }
- if (curBehavior.event == kEventOnClick) {
- javaClick += curJavascript;
- if (gotStat) hitStat = true;
- }
- }
- if (eraseStatOnRestore) {
- javaOut += "dmim('');" ;
- outStat = true;
- }
- var ret = "return document.MM_returnValue";
- if (overStat) javaOver += ret;
- if (outStat) javaOut += ret;
- if (hitStat) javaClick += ret;
- return(gotJavascript);
- }
-
-
- // Write comment for start of JavaScript copy/paste section.
- if (hasStatusMessages) {
- WRITE_HTML_COMMENT("-- Copy the JavaScript code including the opening and closing script tags, and paste");
- WRITE_HTML_COMMENT("it into the head section of the destination document. If the destination document already");
- WRITE_HTML_COMMENT("contains a script section, do not include the script tags when copying. --");
- WRITE_HTML("\n");
- WRITE_HTML_COMMENT("-------------------- BEGIN COPYING THE JAVASCRIPT SECTION HERE --------------------");
- WRITE_HTML("\n");
-
- // Begin Script. Hide Script from non-javascript-enabled browsers.
- WRITE_HTML("<script language=\"JavaScript\">\n");
- WRITE_HTML("<!-- hide this script from non-javascript-enabled browsers\n");
- WRITE_HTML("\n");
-
- // Write function for status bar message.
- WRITE_HTML("// Function that displays status bar messages.\n")
- WRITE_HTML("\n");
- WRITE_HTML("var showMsg = navigator.userAgent != \"Mozilla/4.0 (compatible; MSIE 4.0; Mac_PowerPC)\";\n")
- WRITE_HTML("function dmim(msgStr) {\n")
- WRITE_HTML(" document.MM_returnValue = false;\n")
- WRITE_HTML(" if (showMsg) {\n")
- WRITE_HTML(" window.status = msgStr;\n")
- WRITE_HTML(" document.MM_returnValue = true;\n")
- WRITE_HTML(" }\n")
- WRITE_HTML("}\n")
- WRITE_HTML("\n");
-
- // Stop hiding script from non-javascript-enabled browsers. End script.
- WRITE_HTML("// stop hiding -->\n");
- WRITE_HTML("</script>\n");
- WRITE_HTML("\n");
-
- // End JavaScript copy/paste section.
- WRITE_HTML_COMMENT("-------------------------- STOP COPYING THE JAVASCRIPT HERE --------------------------");
- WRITE_HTML("\n");
- }
-
- // Close head tag.
- WRITE_HTML("</head>\n");
- WRITE_HTML("\n");
-
- // Begin body tag. Set background color to Fireworks document canvas color.
- WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor, "\">\n");
- WRITE_HTML("\n");
-
- // Write comment for start of image map copy/paste section.
- WRITE_HTML_COMMENT("-- Copy the image and map code, and paste the data where ")
- WRITE_HTML_COMMENT("you want the image to appear in the destination document. --")
- WRITE_HTML("\n");
- WRITE_HTML_COMMENT("-------------------------- BEGIN COPYING HERE --------------------------")
- WRITE_HTML("\n");
-
- // If a server-side image map is being export, write comment on replacing file path.
- if (exportDoc.serverMap) {
- WRITE_HTML("<!-- ----------------------------------- NOTE ---------------------------------- --->\n");
- WRITE_HTML("<!-- Replace the text in the following HREF tag with the path to your map file's -->\n");
- WRITE_HTML("<!-- location on the server. The \"", exportDoc.pathBase, ".map\" file generated by Fireworks needs to be -->\n");
- WRITE_HTML("<!-- placed in a directory with a CGI Application capable of interpreting the Image -->\n");
- WRITE_HTML("<!-- Map information. If you are unsure about this, contact your web site -->\n");
- WRITE_HTML("<!-- administrator. -->\n");
- WRITE_HTML("\n");
-
- // Generate link to image map file.
- WRITE_HTML("<a href=\"path_to_map_file/", exportDoc.pathBase, ".map\">\n");
- }
-
- // Write image tag.
- WRITE_HTML("<img src=\"", exportDoc.filename,"\" ");
-
- // Determine width and height of image.
- WRITE_HTML("width=\"", exportDoc.width, "\" height=\"", exportDoc.height, "\"");
-
- // If document has hotspots name the image map.
- if (hasImagemap) {
- WRITE_HTML(" usemap=\"#", exportDoc.imagename, "\"")
- }
-
- // Declare and write alt text.
- var altText = exportDoc.altText;
-
- if (altText!="") {
- WRITE_HTML(" alt=\"", altText, "\"");
- }
-
- // If a server-side image map has been requested write ismap tag.
- if (exportDoc.serverMap) {
- WRITE_HTML(" ismap");
- }
-
- WRITE_HTML(" border=\"0\" >\n");
-
- if (exportDoc.serverMap) {
- WRITE_HTML("</a>\n");
- }
- WRITE_HTML("\n");
-
- // Write client-side image map.
- if (hasImagemap) {
- WRITE_HTML("<map name=\"", exportDoc.imagename, "\">\n");
-
- var i = 0;
- while (i < imagemap.numberOfURLs) {
- var curImagemap = imagemap[i];
- var behaviors = curImagemap.behaviors;
- var javaOver = "";
- var javaOut = "";
- var javaClick = "";
- var gotJavascript = ProcessBehavior(behaviors);
-
- // Write the area tag with shape definitions.
- WRITE_HTML("<area shape=\"");
- WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
- WRITE_HTML("\" coords=\"");
- for (var j=0; j<curImagemap.numCoords; j++) {
- if (j>0) WRITE_HTML(",");
- // polygon has n coords.
- // rect has 2 coords, topLeft, and botomRight.
- // circle has one coord, center; plus radius.
- WRITE_HTML(curImagemap.xCoord(j), ",", curImagemap.yCoord(j));
- }
- if (curImagemap.shape == "circle") {
- // Write the radius for circle hotspots.
- WRITE_HTML(", ", curImagemap.radius);
- }
- WRITE_HTML("\"");
- var href = " href=\"#\"";
- if (curImagemap.hasHref) {
- href = " href=\"";
- href += curImagemap.href;
- href += "\"";
- if (curImagemap.hasTargetText) {
- href += " target=\"";
- href += curImagemap.targetText;
- href += "\"";
- }
- }
-
- // Write status bar message commands.
- if (javaOut != "") {
- WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
- }
- if (javaOver != "") {
- WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
- }
- if (javaClick != "") {
- WRITE_HTML(" onClick=\"", javaClick, "\" ");
- }
- WRITE_HTML(href);
-
- // Write alt text for hotspot.
- var altText = "";
- if (curImagemap.hasAltText) {
- altText = curImagemap.altText;
- } else {
- altText = exportDoc.altText;
- }
-
- if (altText!="") {
- WRITE_HTML(" title=\"", altText, "\"");
- WRITE_HTML(" alt=\"", altText, "\"");
- }
-
- WRITE_HTML(" >\n");
- i++;
- }
-
- // Write the image's default URL here.
- if (exportDoc.hasBackgroundLink && exportDoc.backgroundLink.href != "") {
- var curImagemap = exportDoc.backgroundLink;
- WRITE_HTML("<area shape=\"rectangle\" coords=\"0,0, ", exportDoc.width, ",", exportDoc.height, "\" ");
- WRITE_HTML("href=\"", curImagemap.href, "\"");
- if (curImagemap.hasTargetText) {
- WRITE_HTML("\n target=\"", curImagemap.targetText, "\"");
- }
- var altText = exportDoc.altText;
- if (altText!="") {
- WRITE_HTML(" title=\"", altText, "\"");
- WRITE_HTML(" alt=\"", altText, "\"");
- }
- WRITE_HTML(">\n");
- }
- WRITE_HTML("</map>\n")
- WRITE_HTML("\n");
-
- WRITE_HTML_COMMENT(" Image Map created with Macromedia Fireworks 2.0 ")
- }
-
- WRITE_HTML("\n");
-
- // End map copy/paste section.
- WRITE_HTML_COMMENT("----------------------------- STOP COPYING HERE ----------------------------")
-
- WRITE_HTML("\n");
- WRITE_HTML("</body>\n");
-
- WRITE_HTML("\n");
- WRITE_HTML("</html>\n");
-
-